//
//  TabController.m
//  zhinengfeixing
//
//  Created by hff on 16/2/29.
//  Copyright © 2016年 threeTi. All rights reserved.
//

#import "TabBarController.h"
#import "TTINavigationController.h"
#import "ICUser.h"
#import "UIColor+Utils.h"
#import "HUD.h"
#import "AppMacro.h"
#import "UIImage+Utils.h"
#import "UIAlertView+ICBlockAdditions.h"

@interface TabBarController ()<UITabBarControllerDelegate,UITabBarDelegate>
{
    NSString *telePhone;
}
@end

@implementation TabBarController
- (void)viewDidLoad {
    [super viewDidLoad];

    
    //设置首页
    UIStoryboard *home = [UIStoryboard storyboardWithName:@"Home" bundle:nil];
    TTINavigationController *homeNav1 = [home instantiateInitialViewController];
    
    
    //个人中心
    UIStoryboard *person = [UIStoryboard storyboardWithName:@"Person" bundle:nil];
    TTINavigationController *homeNav2 = [person instantiateInitialViewController];
    
    
    NSArray *controllers = @[homeNav1,homeNav2];
    self.viewControllers = controllers;
    
    

    UITabBarItem *tabBarItem1 = [self createWithTitle:@"上课" image:@"tab_home" seletedImage:@"tab_home_sel"];
     UITabBarItem *tabBarItem2 = [self createWithTitle:@"我的" image:@"tab_person" seletedImage:@"tab_person_sel"];

    
    //修改tabbar图片偏移
//    tabBarItem1.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
//    tabBarItem2.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
//    tabBarItem3.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);

    // 设置文字的样式
    homeNav1.tabBarItem = tabBarItem1;
    homeNav2.tabBarItem = tabBarItem2;
    self.delegate = self;
    
    
    //去掉tabbar顶部黑线
   // self.tabBar.translucent = NO;
   //[self.tabBar setShadowImage:[[UIImage alloc] init]];
}


- (UITabBarItem *)createWithTitle:(NSString *)title image:(NSString *)image seletedImage:(NSString *)selectedImage
{
    UITabBarItem *barItem = [[UITabBarItem alloc]initWithTitle:title image:[[UIImage imageNamed:image]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:selectedImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    // 设置文字的样式
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSForegroundColorAttributeName] = [UIColor colorForHex:@"666666"];
   textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    NSMutableDictionary *selectTextAttrs = [NSMutableDictionary dictionary];
    selectTextAttrs[NSForegroundColorAttributeName] = [UIColor colorForHex:PINK_COCOR];
    selectTextAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    [barItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    [barItem setTitleTextAttributes:selectTextAttrs forState:UIControlStateSelected];
    
    return barItem;
}


-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
    if (viewController == (UIViewController *)[tabBarController.viewControllers objectAtIndex:1]) {
        
      
    }
    
    return YES;
}



- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    
}

@end
